import { Component, Input, OnInit } from "@angular/core";

import { AppGlobalService } from "../../shared/service/app-global.service";

@Component({
  selector: "app-block-link",
  templateUrl: "./block-link.component.html",
  styleUrls: ["./block-link.component.scss"]
})
export class BlockLinkComponent implements OnInit {
  @Input() tagData: any;

  aWidth: string;

  constructor(private appGlobalService: AppGlobalService) {}

  ngOnInit() {
    console.log(this.tagData);
    this.aWidth = 100 / this.tagData.colNum + "%";
  }

  jumpToPage(item) {
    if (item.target) {
      const sessionId = localStorage.getItem("sessionId");
      const pageParams = {
        pageId: item.target,
        params: {},
        sessionId: sessionId
      };
      if (item.params !== undefined) {
        pageParams.params = item.params;
      }

      this.appGlobalService.goToForward(pageParams);
    } else {
      return;
    }
  }
}
